using System;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using QuickTest.Core.Compilation;

namespace QuickTest.Tests.Common
{
    [TestFixture]
    public class FileUriTests
    {
        private const string FilePath = "c:/Temp/A File Path.sln";
        private const string NonFileUri = "http://www.something.com";

        [Test]
        public void ArgumentException_Thrown_If_Null_Uri_Passed()
        {
            TestUtils.AssertThrows<ArgumentNullException>(() => new FileUri(null), "ArgumentNullException should have been thrown.");
        }

        [Test]
        public void ArgumentException_Thrown_If_Uri_Is_Not_File_Uri()
        {
            Exception ex = TestUtils.AssertThrows<ArgumentException>(() => new FileUri(NonFileUri), "ArgumentException should have been thrown.");

            Assert.That(ex.Message, Is.EqualTo("Uri must be a file uri"), "Exception message should have been 'Uri must be a file uri'");
        }

        [Test]
        public void Can_Get_Uri_AbsolutePath()
        {
            var uri = new Uri(FilePath);
            var fileUri = new FileUri(FilePath);

            Assert.That(fileUri.AbsolutePath, Is.EqualTo(uri.AbsolutePath), "FileUri.AbsolutePath should be equal to Uri.AbsolutePath");
        }
    }
}